package 回溯;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

public class q78子集 {

    class Solution {
        List<List<Integer>> res = new ArrayList<>();
        LinkedList<Integer> path = new LinkedList<>();
        public List<List<Integer>> subsets(int[] nums) {
            res.add(new ArrayList<>(path)); // 先放入一个空集合
            backtracking(nums, 0);
            return res;
        }

        public void backtracking(int[] nums, int startIndex) {

            for (int i = startIndex; i < nums.length; i++) {  // 不需要剪
                path.push(nums[i]);
                res.add(new ArrayList<>(path));
                backtracking(nums, i + 1);
                path.pop();
            }
        }
    }
}
